﻿Imports DevExpress.XtraGrid.Views.Grid

Public Class Frm_GridControl


    Private Sub Frm_GridControl_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'PcvgppDataSet.bacsi' table. You can move, or remove it, as needed.
        Me.BacsiTableAdapter.Fill(Me.PcvgppDataSet.bacsi)

    End Sub

    Private Sub IGridView1_InvalidRowException(sender As Object, e As DevExpress.XtraGrid.Views.Base.InvalidRowExceptionEventArgs) Handles IGridView1.InvalidRowException
        e.ExceptionMode = DevExpress.XtraEditors.Controls.ExceptionMode.NoAction
    End Sub

    Private Sub IGridView1_ValidatingEditor(sender As Object, e As DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs) Handles IGridView1.ValidatingEditor
        Dim View As GridView = sender
        If View.FocusedColumn.FieldName = "chinhanh" Then
            If e.Value = "abc" Then
                e.Valid = False
                e.ErrorText = "Không thể bằng rỗng"
            End If
        End If
    End Sub

    Private Sub SimpleButton1_Click(sender As System.Object, e As System.EventArgs) Handles SimpleButton1.Click
        IGridView1.Focus()
        IGridView1.AddNewRow()
        IGridView1.FocusedRowHandle = 4
        IGridView1.FocusedColumn = IGridView1.VisibleColumns(0)
        IGridView1.ShowEditor()
    End Sub
End Class